"""
文件上传相关的数据模型
"""
from sqlalchemy import Column, Integer, String, DateTime, BigInteger
from sqlalchemy.sql import func
from app.core.database import Base


class FileUpload(Base):
    """
    文件上传记录表
    """
    __tablename__ = "file_uploads"
    
    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    filename = Column(String, nullable=False, comment="保存后的文件名")
    original_filename = Column(String, nullable=False, comment="原始文件名")
    file_path = Column(String, nullable=False, comment="文件保存路径")
    file_size = Column(BigInteger, nullable=False, comment="文件大小(字节)")
    file_type = Column(String, nullable=True, comment="文件类型")
    upload_time = Column(DateTime(timezone=True), server_default=func.now(), comment="上传时间")
    status = Column(String, default="success", comment="上传状态")
    departure_retention_status = Column(String, default="未分析", comment="离场/停留识别状态: 未分析/已分析/分析中")
    background_activity_status = Column(String, default="未分析", comment="背景/活动区分状态: 未分析/已分析/分析中")
    anomaly_detection_status = Column(String, default="未分析", comment="异常检测状态: 未分析/已分析/分析中")
    created_at = Column(DateTime(timezone=True), server_default=func.now(), comment="创建时间")
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), comment="更新时间")